package com.example.group.network.express_plus_app.Dao.UserDao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.example.group.network.express_plus_app.data.model.LoggedInUser;

import java.util.List;

/**
 * @author 夏宁
 * @email 1941512303@qq.com
 * @date 2021/3/24 0:08
 */
@Dao
public interface UserDao {
    @Query("SELECT * FROM user where phone=:phone")
    LoggedInUser loadUserByPhone(String phone);

    @Query("SELECT * FROM user")
    LiveData<List<LoggedInUser>> loadUsersLiveData();

    @Query("SELECT * FROM user")
    List<LoggedInUser> loadUsers();

    @Update
    void updateUserDeliveryAddress(LoggedInUser loggedInUser);


    @Insert
    void insertUser(LoggedInUser user);

    //使用主键删除user,匹配主键
    @Delete
    void delete(LoggedInUser user);
}
